/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-07-30 16:04:37
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-07 15:49:42
 * @FilePath: \dwys_web\assets\script\phoenix\messageHandle\s2cRoomUpCyLevel_MessageHandle.ts
 * @Description: 
 */
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { IMessageHandle } from "../../../../extensions/phoenix-plugin-client/assets/core/interface/IMessageHandle";
import messageManager from "../../../../extensions/phoenix-plugin-client/assets/core/managers/message.manager";
import { GameEvent } from "../../common/event/GameEvent";
import { OpcodeApp } from "../define/opcode.define";
import * as proto from "../protoc/ts/proto_app.js";

export default class S2CRoomUpCyLevel implements IMessageHandle{
    handleMessage(msgData: any): void {
        let response = msgData as proto.s2c_UpRoomCyLevel;
        console.log("S2CRoomUpCyLevel", response);
        if (response.base!.code == 0) {
            for (let i = 0; i < response.roomPmtInfo!.length; i++) {
                oops.message.dispatchEvent(GameEvent.UpdateRoomPmt, response.roomPmtInfo[i]);
                oops.message.dispatchEvent(GameEvent.AddGameMsgInfo, "房间ID [" + response.roomPmtInfo[i]!.roomId + "], 摆件[" + response.roomPmtInfo[i]!.name + 
                "] 升阶成功] 当前阶级 lv." + response.roomPmtInfo[i]!.level);
            }
        }else{
            oops.message.dispatchEvent(GameEvent.AddGameMsgInfo, "摆件升阶失败 [" + response.base!.msg + "]" );
        }
    }
}

messageManager.registerHandle(OpcodeApp.Opcode_SC_ROOM_UP_CY_LEVEL, new S2CRoomUpCyLevel());